package com.atm.controller;

import com.atm.annotation.NeedLogin;
import com.atm.service.AccountService;
import com.atm.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class DepositController {

    @Resource
    private AccountService accountService;

    @ApiOperation("存款")
    @NeedLogin
    @PostMapping("/deposit")
    public Result<Boolean> deposit(Long depositAmount , HttpServletRequest httpServletRequest){
        if(depositAmount>0)
            return accountService.deposit(depositAmount, httpServletRequest.getAttribute("accountNo").toString());
        return Result.fail("输入错误，存款必须大于0");
    }
}
